import React from 'react'
import { createAppContainer, createMaterialTopTabNavigator } from 'react-navigation'
import TabBar from './TabBar'
import routeNames from '../../../../utils/routeNames'
import Mine from './mine/mine'
import Found from './found/found'
import Social from './social/social'
import Video from './video/video'
let tabBar = React.createRef();
let openDrawer = null;
function onOpenDrawer() {
  openDrawer && openDrawer()
}
const navigator = createMaterialTopTabNavigator({
  [routeNames.mine]: Mine,
  [routeNames.found]: Found,
  [routeNames.social]: Social,
  [routeNames.video]: Video
},
{
  initialRouteName: routeNames.found,
  tabBarComponent: props => <TabBar ref={tabBar} {...props} onOpenDrawer={onOpenDrawer}/>
})

const Container = createAppContainer(navigator)

export default props => {
  openDrawer = props.openDrawer;
  return <Container/>
}